package ioperation;

import Book.Book;
import Book.BookShelf;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    @Override
    public void work(BookShelf bookShelf) {
        System.out.println("#########归还图书#########");
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入归还图书书名：");
        String name=scanner.nextLine();
        int currentSize= bookShelf.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book=bookShelf.getBooks(i);
            if(book.getName().equals(name)&&book.isBorrowed()==true){
                book.setBorrowed(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("找不到啊，没有你要归还的书呢亲亲！！！！！！！！！！");
    }
}

